package com.yltrcc.blog.controller.api;

import com.yltrcc.blog.dao.SysUserDao;
import com.yltrcc.blog.model.model.ApiResponse;
import com.yltrcc.blog.model.model.ArticleV3List;
import com.yltrcc.blog.model.model.BaseApiResponse;
import com.yltrcc.blog.model.model.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@RestController
@RequestMapping(value = "/api/es")
public class EsApiController {

  /*  @Autowired
    private SysUserDao sysUserDao;*/

    @GetMapping("/saveTest")
    public BaseApiResponse saveTest() {
        List<String> list = new ArrayList<>();
        list.add("teacher");
        list.add("student");
        list.add("admin");
        list.add("leader");
        for (int i = 0; i < 1000; i++) {
            int toIndex = new Random(1).nextInt(4);
            SysUser build = SysUser.builder()
                    .password("123456")
                    .username("AI码师")
                    .level(i)
                    .roles(list.subList(0, toIndex))
                    .build();
           /* sysUserDao.save(build);*/
        }
        System.out.print("结束");

        return new BaseApiResponse();
    }

    @GetMapping("/testFindAll")
    public BaseApiResponse testFindAll() {
        /*Iterable<SysUser> all = sysUserDao.findAll();
        all.forEach((sysUser)->{
            System.out.printf(sysUser.getId());
        });*/

        return new BaseApiResponse();
    }

}
